﻿using Microsoft.EntityFrameworkCore;
using Open.Product.Domain.Model;

namespace LogicApi.EntityFrameworkCore
{
    public class LogicApiDbContext : DbContext
    {

        public LogicApiDbContext(DbContextOptions<LogicApiDbContext> options) : base(options)
        {

        }

        public DbSet<Product> Products { get; set; }
        public DbSet<ProductCategory> ProductCategory { get; set; }
        public DbSet<ProductStandard> ProductStandard { get; set; }
        public DbSet<ProductStandardBarCode> Productstandardbarcodes { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
            builder.Entity<Product>().ToTable("BaseProducts").HasIndex(t => new { t.TenantId });
            builder.Entity<ProductCategory>().ToTable("baseproductcategories").HasIndex(t => new { t.TenantId });
            builder.Entity<ProductStandard>().ToTable("baseproductstandards").HasIndex(t => new { t.TenantId });
            builder.Entity<ProductStandardBarCode>().ToTable("baseproductstandardbarcodes").HasIndex(t => new { t.TenantId });
        }

    }
}